class AdminController < ApplicationController
  scaffold :category, :suffix => true
  scaffold :article, :suffix => true
  scaffold :comment, :suffix => true
  scaffold :user, :suffix => true
  scaffold :search_log, :suffix => true
  
  COMMENTS_PER_PAGE = 10
  
  
  def index
    @articles = Article
    @categories = Category
    @comments = Comment
  end
  def list_comment_approved
    @comment_pages, @comments = paginate(:comments, :conditions =>"approved=1",:per_page => COMMENTS_PER_PAGE)
    render "admin/list_comment"
  end
  def list_comment_not_approved
    @comment_pages, @comments = paginate(:comments, :conditions =>"approved=0",:per_page => COMMENTS_PER_PAGE)
    render "admin/list_comment"
  end
  def approve_comment
    @comments = Comment.find(params[:id])
    @comments.approved = true
    @comments.save
    @comment_pages, @comments = paginate(:comments, :per_page => COMMENTS_PER_PAGE)
    render "admin/list_comment"
  end
  def publish_article
    @articles = Article.find(params[:id])
    @articles.publish = true
    @articles.save
    @article_pages, @articles = paginate(:articles, :per_page => COMMENTS_PER_PAGE)
    render "admin/list_article"
  end
  def list_comment
     @comment_pages, @comments = paginate(:comments, :per_page => COMMENTS_PER_PAGE)
  end
  def list_article
     @article_pages, @articles = paginate(:articles, :per_page => COMMENTS_PER_PAGE)
  end  
end
